package net.jueb.frameWorkDemo.mvc4mod.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import net.jueb.frameWorkDemo.mvc4mod.bean.Account;
import net.jueb.frameWorkDemo.mvc4mod.mapper.AccountMapper;
import net.jueb.frameWorkDemo.mvc4mod.service.IAccountService;

@Transactional//类事务
@Component
public class AccountServiceImpl_tx_Annotation implements IAccountService {

	@Autowired
	private AccountMapper mapper;
	
	@Transactional//方法事务
	@Override
	public Account registAccount(String name,String pwd) {
		Account result=null;
		/**
		 * 自动注入
		 */
		AccountMapper mapper=this.mapper;
		Account a=new Account();
		a.setNickName(name);
		a.setPasswd(pwd);
		try {
			mapper.insert(a);
			result=a;
		} catch (Exception e) {
		}
		return result;
	}
}
